package cn.edu.jnu.supershopper.Game;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;


public class Explosion extends FlyingObject{
    Rect rect1 = null,rect2;
    int step = 0;
    public Boolean isStart = false;

    public Explosion(Context context, int resourceId) {
        super(context, resourceId);
        width = bitmap.getWidth()/8;
        rect2 = new Rect(0,-100,100,0);
    }

    @Override
    public void draw(Canvas cv, Paint pt) {
        cv.drawBitmap(bitmap,rect1,rect2,pt);
    }

    //获取爆炸坐标矩形
    public void setExplosionP(Enemy enemy){
        rect2 = new Rect(enemy.posX,enemy.posY,enemy.posX+width,enemy.posY+height);
        isStart = true;
    }

    //在循环中调用逐帧爆炸动画
    public void startExplosion(){
        rect1 = new Rect(step*width,0,(step+1)*width,height);
        while (step<4) {
            step++;
        }
        step = 0;
        isStart = false;
    }
}

